﻿/*
 *  RetroGlider v1.0
    Copyright (C) 2013 Alexander Blohmé

    This program is free software; you can redistribute it and/or
    modify it under the terms of the GNU General Public License
    as published by the Free Software Foundation; either version 2
    of the License, or (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 */


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.SQLite;

namespace RetroGlider
{
    public class SQLHandler
    {


        SQLiteConnection connector = new SQLiteConnection("URI=file:class_data.dat");

        public SQLHandler()
        {
                connector.Open(); 
        }

   
        public List<string> GetClassSpellNames(string class_name)
        {
            string stm = "SELECT spell_name FROM " + class_name;
            SQLiteCommand cmd = new SQLiteCommand(stm, connector);
            SQLiteDataReader rdr = cmd.ExecuteReader();
            List<string> spellNames = new List<string>();

            while (rdr.Read())
            {
                spellNames.Add(rdr.GetString(0));
            }
            return spellNames;
        
        }

        public int GetSpellCooldownFromSpellName(string class_name, string spell_name)
        {
            return 0;
        }


        public void SaveData(string settings_tab, string row, string value)
        {
            string stm = "UPDATE " + settings_tab + " SET " + row + "='" + value + "'";
            SQLiteCommand cmd = new SQLiteCommand(stm, connector);
            SQLiteDataReader rdr = cmd.ExecuteReader();

        }

        public string LoadData(string settings_tab, string row)
        {
            string stm = "SELECT " + row + " FROM " + settings_tab;
            SQLiteCommand cmd = new SQLiteCommand(stm, connector);
            SQLiteDataReader rdr = cmd.ExecuteReader();

            while (rdr.Read())
            {

                return rdr.GetString(0);

            }
            return "";

        }

    }
}
